package cn.gov.cbrc.east.util;

import java.io.File;
import java.io.Serializable;

/**
 * 项目名称：EastUpload<br>
 * *********************************<br>
 * <P>类名称：FileTruncate</P>
 * *********************************<br>
 * <P>类描述：文件分割对象--将大文件分割异步校验</P>
 * 创建人：王川<br>
 * 创建时间：Jan 8, 2016 10:19:26 AM<br>
 * 修改人：王川<br>
 * 修改时间：Jan 8, 2016 10:19:26 AM<br>
 * 修改备注：<br>
 * @version 1.0<br>    
 */
@SuppressWarnings("serial")
public class FileTruncate implements Serializable{
	
	/** 文件分割序号 **/
	private int _index;
	/** 分割文件位置 **/
	private String _filePath;
	/** 文件开始位置 **/
	private long _startPosition;
	/** 文件结束位置 **/
	private long _endPosition;
	/** 分割大小 **/
	private long _truncateSize;
	/** 分割文件行数 **/
	private int row = 0;
	/** 分割文件校验成功条数 **/
	private int _succRows = 0;
	/** 分割文件校验失败 **/
	private int _failRows = 0;
	/** 生成日志名称 **/
	private String loggerName;
	/**警告级别字段数量**/
	private int _warningFields;
	/**错误级别字段数量**/
	private int _errorFields;
	
	public FileTruncate(){}
	
	public FileTruncate(String filePath){
		_index  = 1;
		_filePath = filePath;
		_startPosition = 0;
	}
	
	public FileTruncate(int index, String filePath){
		_index  = index;
		_filePath = filePath;
	}
	
	public int get_index() {
		return _index;
	}
	
	public void set_index(int _index) {
		this._index = _index;
	}
	
	public String get_filePath() {
		return _filePath;
	}
	
	public void set_filePath(String path) {
		_filePath = path;
	}
	
	public long get_startPosition() {
		return _startPosition;
	}
	
	public void set_startPosition(long position) {
		_startPosition = position;
	}
	
	public long get_endPosition() {
		return _endPosition;
	}
	
	public void set_endPosition(long position) {
		_endPosition = position;
	}
	
	public long get_truncateSize() {
		return _truncateSize;
	}

	public void set_truncateSize(long size) {
		_truncateSize = size;
	}
	
	//分割文件大小
	public long getFileSize(){
		return _endPosition-_startPosition;
	}
	
	public int get_succRows() {
		return _succRows;
	}

	public void set_succRows(int _succRows) {
		this._succRows = _succRows;
	}

	public int get_failRows() {
		return _failRows;
	}

	public void set_failRows(int _failRows) {
		this._failRows = _failRows;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public String getLoggerName() {
		return loggerName;
	}

	public void setLoggerName(String loggerName) {
		this.loggerName = loggerName;
	}
	
	public int get_warningFields() {
		return _warningFields;
	}

	public void set_warningFields(int _warningFields) {
		this._warningFields = _warningFields;
	}

	public int get_errorFields() {
		return _errorFields;
	}

	public void set_errorFields(int _errorFields) {
		this._errorFields = _errorFields;
	}

	/**
	 * <p>方法描述: 获取文件名</p>
	 * <p>方法备注: </p>
	 * @return
	 * <p>创建人：王川</p>
	 * <p>创建时间：Jan 14, 2016 11:23:23 AM</p>
	 *
	 */
	public String getFileName() {
		int index = _filePath.lastIndexOf(File.separator);
		if (index < 0)
			return _filePath;
		return _filePath.substring(index + 1);
	}

	@Override
	public String toString() {
		return "FileTruncate [_index=" + _index + ", _filePath=" + _filePath
				+ ", _startPosition=" + _startPosition + ", _endPosition="
				+ _endPosition + ", _truncateSize=" + _truncateSize + ", row="
				+ row + ", _succRows=" + _succRows + ", _failRows=" + _failRows
				+ ", loggerName=" + loggerName + "]";
	}
	
}
